package com.serkol.ams.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.serkol.constant.AuthConstant;
import com.serkol.utils.Validator;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 
 * @TableName pictures
 */
@TableName(value ="pictures")
@Data
public class Pictures implements Serializable {
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 
     */
    private Integer h;

    /**
     * 
     */
    private Integer w;

    /**
     * 
     */
    private String type;

    /**
     * 
     */
    private String url;

    /**
     * 
     */
    private Integer istype;

    /**
     * 
     */
    private String appcationName;

    /**
     * 
     */
    private Date date;

    /**
     * 
     */
    private Long requestId;

    /**
     * 
     */
    private String name;


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
    public String getUrl() {
        if (!Validator.IsUrl(url)) {
            StringBuilder sb = new StringBuilder();
            sb.append(AuthConstant.getPathUrl());
            sb.append(url);
            return sb.toString();
        } else {
            return url;
        }

    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Pictures other = (Pictures) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getH() == null ? other.getH() == null : this.getH().equals(other.getH()))
            && (this.getW() == null ? other.getW() == null : this.getW().equals(other.getW()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
            && (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
            && (this.getIstype() == null ? other.getIstype() == null : this.getIstype().equals(other.getIstype()))
            && (this.getAppcationName() == null ? other.getAppcationName() == null : this.getAppcationName().equals(other.getAppcationName()))
            && (this.getDate() == null ? other.getDate() == null : this.getDate().equals(other.getDate()))
            && (this.getRequestId() == null ? other.getRequestId() == null : this.getRequestId().equals(other.getRequestId()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getH() == null) ? 0 : getH().hashCode());
        result = prime * result + ((getW() == null) ? 0 : getW().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getUrl() == null) ? 0 : getUrl().hashCode());
        result = prime * result + ((getIstype() == null) ? 0 : getIstype().hashCode());
        result = prime * result + ((getAppcationName() == null) ? 0 : getAppcationName().hashCode());
        result = prime * result + ((getDate() == null) ? 0 : getDate().hashCode());
        result = prime * result + ((getRequestId() == null) ? 0 : getRequestId().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", h=").append(h);
        sb.append(", w=").append(w);
        sb.append(", type=").append(type);
        sb.append(", url=").append(url);
        sb.append(", istype=").append(istype);
        sb.append(", appcationName=").append(appcationName);
        sb.append(", date=").append(date);
        sb.append(", requestId=").append(requestId);
        sb.append(", name=").append(name);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}